package pattern22;

/**
 * p267
 * 享元模式
 * @author wdl
 */
public class FlyweightPattern {
    public static void main(String[] args) {
        //代码的外部状态
        int extrinsicState=22;
        FlyweightFactory flyweightFactory=new FlyweightFactory();

        IFlyweight flyweightX=flyweightFactory.getFlyweight("X");
        flyweightX.operation(--extrinsicState);

        IFlyweight flyweightY=flyweightFactory.getFlyweight("Y");
        flyweightY.operation(--extrinsicState);

        IFlyweight flyweightZ=flyweightFactory.getFlyweight("Z");
        flyweightZ.operation(--extrinsicState);

        IFlyweight unsharedFlyweight=new UnsharedConcreteFlyweight();
        unsharedFlyweight.operation(--extrinsicState);
    }
}
